package com.itheima.exerciseTest.test50_59;

        import java.io.BufferedOutputStream;
        import java.io.FileOutputStream;
        import java.io.IOException;

/*
    在D盘下，有一c.txt 文件中内容为：HelloWorld
    在c.txt文件原内容基础上，添加五句 I love java，而且要实现一句一行操作(注：原文不可覆盖)。
 */
public class Test55 {
    public static void main(String[] args) {
        BufferedOutputStream bos = null;

        String str = "I love java";
        String[] split = str.split(" ");

        try {
            bos = new BufferedOutputStream(new FileOutputStream("backBurner\\c.txt",true));
            bos.write("\r\n".getBytes());
            for (int i = 0; i < split.length; i++) {
                bos.write(split[i].getBytes());
                bos.write("\r\n".getBytes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(bos != null){
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
